var app = getApp(),
  $ = require("../../utils/httpHelper.js")
Page({
  data: {
    shoplist: [],
    shopname: '',
    // tab切换  
    currentTab: 1,
  },
  onShareAppMessage: function (res) {
    app.shareApp(res)
  },
  onLoad: function (option) {
    this.getData()
  },
  getData(){
    $.httpPost("mendian_list", {  type_id: this.data.currentTab }, (data, err) => {
      this.setData({
        shoplist: data.list,
      })
    })
  },
  clicktab(e) {
    console.log(e.target)
    let tab = e.target.dataset.tab
    if (this.data.currentTab != tab) {
      this.setData({
        currentTab: tab,
        page: 1
      })
      this.getData()
    }
  },
  toindex(e) {
    let id = e.currentTarget.dataset.id
    let name = e.currentTarget.dataset.name
    wx.setStorageSync('shop_id', id);
    wx.setStorageSync('shop_name', name);
    wx.reLaunch({
      url: '/pages/index/index',
    })
  }

});